package it.koutifaris.travianmap.tile.boundscache.list;

import it.koutifaris.travianmap.tile.TileBounds;
import it.koutifaris.travianmap.tile.boundscache.BoundsCache;

import java.util.ArrayList;
import java.util.List;

public class BoundsListCache implements BoundsCache {

	private final List<TileBounds> boundsList;

	public BoundsListCache() {
		this.boundsList = new ArrayList<TileBounds>();
	}

	@Override
	public void addBounds(TileBounds bounds) {
		boundsList.add(bounds);

	}

	@Override
	public boolean removeBounds(TileBounds bounds) {
		return boundsList.remove(bounds);
	}

	@Override
	public boolean containsPoint(int x, int y) {
		for (TileBounds bounds : boundsList) {
			if (bounds.containsPoint(x, y)) {
				return true;
			}
		}

		return false;
	}

}
